package cn.kxm.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.kxm.dao.SellOrderBillMapper;
import cn.kxm.pojo.SellOrderBill;
import cn.kxm.pojo.SellOrderBillDetail;
import cn.kxm.service.SellOrderBillService;
@Service("sellOrderBillServiceImpl")
public class SellOrderBillServiceImpl implements SellOrderBillService{
    @Autowired
	private SellOrderBillMapper sobm;

    @Override
	public List<Map<String, Object>> getSellOrderBills(String code,
			String starttime, String endtime, String customName,
			Integer pageNo, Integer pageSize) {
		return sobm.getSellOrderBills(code, starttime, endtime, customName, pageNo, pageSize);
	}
    
	@Override
	public int getSellOrderBillCount(String code, String starttime,
			String endtime, String customName) {
		return sobm.getSellOrderBillCount(code, starttime, endtime, customName);
	}

	@Override
	public Map<String, Object> getSellOrderBillByCode(String code) {
		return sobm.getSellOrderBillByCode(code);
	}

	@Override
	public List<Map<String, Object>> getfindPartsBySellCode(String sellcode) {
		return sobm.getfindPartsBySellCode(sellcode);
	}

	@Override
	public int addSellOrderBill(SellOrderBill sellOrderBill) {
		return sobm.addSellOrderBill(sellOrderBill);
	}

	@Override
	public int addSellOrderBillDetail(SellOrderBillDetail sellOrderBillDetail) {
		return sobm.addSellOrderBillDetail(sellOrderBillDetail);
	}
	
	@Override
	public int addSellOrder(SellOrderBill sellOrderBill,List<SellOrderBillDetail> sellOrderBillDetails) {
        int temp=0; 
		addSellOrderBill(sellOrderBill);
		temp++;
         for (SellOrderBillDetail sellOrderBillDetail : sellOrderBillDetails) {
        	 addSellOrderBillDetail(sellOrderBillDetail);
        	 temp++;
		 }
         return temp;
	}
	
	@Override
	public int updateSellOrderBill(SellOrderBill sellOrderBill) {
		return sobm.updateSellOrderBill(sellOrderBill);
	}

	@Override
	public int updateSellOrderBillDetail(SellOrderBillDetail sellOrderBillDetail) {
		return sobm.updateSellOrderBillDetail(sellOrderBillDetail);
	}
    
	@Override
	public int updateSellOrder(SellOrderBill sellOrderBill,List<SellOrderBillDetail> sellOrderBillDetails) {
        int temp=0; 
        updateSellOrderBill(sellOrderBill);
		temp++;
		delSellOrderBillDetail(sellOrderBill.getCode());
		temp++;
         for (SellOrderBillDetail sellOrderBillDetail : sellOrderBillDetails) {
        	 addSellOrderBillDetail(sellOrderBillDetail);
        	 temp++;
		 }
         return temp;
	}
	
	@Override
	public List<SellOrderBillDetail> getSellOrderBillDetailListByBillCode(
			String billCode) {
		return sobm.getSellOrderBillDetailListByBillCode(billCode);
	}

	@Override
	public int delSellOrderBill(String code) {
		return sobm.delSellOrderBill(code);
	}

	@Override
	public int delSellOrderBillDetail(String billCode) {
		return sobm.delSellOrderBillDetail(billCode);
	}
	public int delOne(String code){
		int temp=0;
		if(delSellOrderBillDetail(code)>0&&delSellOrderBill(code)>0){
			temp=1;
		}
		return temp;
	}
	
	@Override
	public List<Map<String, Object>> getOfferPriceBills(String code,
			String starttime, String endtime, String customName,
			Integer pageNo, Integer pageSize) {
		System.out.println(customName);
		
		return sobm.getOfferPriceBills(code, starttime, endtime, customName, pageNo, pageSize);
	}

	@Override
	public int getOfferPriceBillsCount(String code, String starttime,
			String endtime, String customName) {
		return sobm.getOfferPriceBillsCount(code, starttime, endtime, customName);
	}

	@Override
	public int updateAuditing(String code) {
		return sobm.updateAuditing(code);
	}

	@Override
	public int updateUnaudited(String code) {
		return sobm.updateUnaudited(code);
	}

	
	
}
